package com.org.mapper;

import com.org.entity.Poem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.security.core.parameters.P;

import java.util.List;

/**
* @author Rainy-Heights
* @description 针对表【poem】的数据库操作Mapper
* @createDate 2023-03-08 10:21:45
* @Entity com.org.entity.Poem
*/
public interface PoemMapper {

    @Select("select * from renjiancihua.poem")
    List<Poem> selectAllPoem();


    //随机获得一首诗

    @Select("select count(1) from renjiancihua.poem")
    int getPoemCount();


    @Select("select * from renjiancihua.poem where id=#{id}")
    Poem getPoem(int id);

    @Delete("delete from renjiancihua.poem where id=#{id}")
    int deletePoem(int id);

    @Insert("insert into renjiancihua.poem(author, title, content, id) VALUES (#{author},#{title},#{content},#{id})")
    int addPoem(@Param("author") String author, @Param("title") String title, @Param("content") String content, @Param("id")int id);


}
